<%@ page pageEncoding="UTF-8"%>
<%@ include file="../commons/head.jsp"%>
<title>合同高级查询</title>
<style type="text/css">
	.button{width: 100px;height: 30px;margin:3px 20px 3px 0;padding-top: 3px;}
	*{font-size: 14px;}
	.th td{font-weight: 700;}
	/* label{margin: 0 10px 0 18px;font-weight: 500;height: 25px;line-height: 25px;} */
     .control-label{padding: 0;font-weight: bold;}
     .diaform{margin: 20px auto;}
     h3{border-bottom:1px solid #ddd;padding-bottom:5px;width: 98%;  }
     .datagrid-view{border-top:1px solid #ddd;margin-top: 8px;}
     .datagrid-pager{border-bottom:1px solid #ccc;}
     hr{margin:15px 0 13px 0 ;background-color: #ddd;height: 1px;border: 0; width: 120%;}
     .jianju{margin-left:15px; }
     .datagrid-htable{
     font-weight:bold;
	/* background-color: #148CCA; */
	}
	.demo_line_01{
    
    margin: 5px 0;
    font-size: 50px;
    line-height: 1px;
    text-align: center;
	}
	.demo_line_01 .line{
	display:inline-block;
	   width:47.8%;
	   height:1px;
	   background:#ddd;
	   vertical-align:middle;
	   margin-top:8px;
	}
	.container-fluid{
	padding-left: 15px;
	}
	.datagrid-ftable td div{
		font-size: larger;
	
	}
	#pulldown{
		margin-top: 20px;
	}
	
/* td.datagrid-header-over{
	background: #148CCA !important;
} */

.datagrid-ftable {
	color: red;
	font-weight: bold;
}
.datagrid-body {
height:300px !important;
}
.datagrid-view {
height:360px !important;
}


</style>

<script type="text/javascript">
var queryInit = true;
	
$(function(){
	function scrollShow(datagrid) {
	    datagrid.prev(".datagrid-view2").children(".datagrid-body").html("<div style='width:" + datagrid.prev(".datagrid-view2").find(".datagrid-header-row").width() + "px;border:solid 0px;height:1px;'></div>");
	};
	scrollShow($("#ac"));
	
	$('#ssgs').combobox({
		onLoadSuccess : function() {
			var data = $('#ssgs').combobox('getData');
			if (data) {
				$("#ssgs").combobox('select', data[0].id);
			}
		}
	}); 
	
	$("#search").click(function(){debugger
		var params = {
			customerName:$("#customerName").val(),
			customerPhone:$("#customerPhone").val(),
			status:$("#htzt").combobox("getValue"),
			recom:$("#recom").val(),
			underCompany:$("#ssgs").combobox("getValue"),
			applstartTime:$("#applstartTime").datebox('getValue'),
			applendTime:$("#applendTime").datebox('getValue'),
			loanstartTime:$("#loanstartTime").datebox('getValue'),
			loanendTime:$("#loanendTime").datebox('getValue'),
		};
		$("#ac").datagrid({url:"${ctx}/contractadvancedquery/findlist",queryParams:params});
		init();
	});
});	
function init(){debugger
	var params = {
		customerName:$("#customerName").val(),
		customerPhone:$("#customerPhone").val(),
		status:$("#htzt").combobox("getValue"),
		recom:$("#recom").val(),
		underCompany:$("#ssgs").combobox("getValue"),
		applstartTime:$("#applstartTime").datebox('getValue'),
		applendTime:$("#applendTime").datebox('getValue'),
		loanstartTime:$("#loanstartTime").datebox('getValue'),
		loanendTime:$("#loanendTime").datebox('getValue'),
	};
	$.ajax({
		url:"${ctx}/contractadvancedquery/findlistSUM",
		data:params,
		success:function(data){debugger
			if(data.approvalSum != "" && data.approvalSum != null){
				$("#approvalAmountSum").textbox('setValue',data.approvalSum);
			}else{
				$("#approvalAmountSum").textbox('setValue',0);
			}
			if(data.totalSum != "" && data.totalSum != null){
				$("#totalAmountSum").textbox('setValue',data.totalSum);
			}else{
				$("#totalAmountSum").textbox('setValue',0);
			}
		}
		
	});
	
}
function showTexts(value, row, index){debugger
	var status="";
	if(value=="90"){
		status="已结束";
	}else if(value == "10"){
		status="逾期中";
	}else if(value =="20"){
		status="执行中";
	}else if(value =="30"){
		status="待二审";
	}else if(value =="40"){
		status="待一审";
	}else if(value =="50"){
		status="录入中";
	}else if(value =="60"){
		status="待放款";
	}else if(value =="70"){
		status="已作废";
	}
	return status;
}

function showLinks(value, row, index){debugger
	//alert(row.status);
	var link="";
	if(value=="90" || value == "10" || value =="20"){
		link="<a href='#'>执行详情</a>";
	}else{
		link="";
	}
	return link;
}


function reload(closeFlag){
	/* if(reloadFlag){
		$("#forceAmount").form('clear');
	} */
	/* if(closeFlag){
		$("#dlg").dialog('close');
	} */
	$("#ac").datagrid('reload');
} 

 function closeDlg(){
	$("#ac").datagrid('reload');
	$('#dlg').dialog('close');
}; 

function rowStyle(index,row){
	if (index%2==0){     
        return 'background-color:lightcyan;';     
    }     
}

$(function(){
    $("#customerPhone").textbox('textbox').bind('keyup', function(e){
	        $("#customerPhone").textbox('setValue', $(this).val().replace(/\D/g,''));
    });
});

function formatMoney(number) {
number = Math.round(number * 100) / 100;
return outputDollars(Math.floor(number - 0) + '') + outputCents(number - 0);
}
function outputDollars(number) {
if (number.length <= 3)
	return (number == '' ? '0' : number);
else {
	var mod = number.length % 3;
	var output = (mod == 0 ? '' : (number.substring(0, mod)));
	for (i = 0; i < Math.floor(number.length / 3); i++) {
		if ((mod == 0) && (i == 0))
			output += number.substring(mod + 3 * i, mod + 3 * i + 3);
		else
			output += ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
	}
	return (output);
}
}
function outputCents(amount) {
amount = Math.round(((amount) - Math.floor(amount)) * 100);

if (amount == 10 || amount == 20 || amount == 30 || amount == 40
		|| amount == 50 || amount == 60 || amount == 70 || amount == 80
		|| amount == 90) {
	amount = (amount.toString()).substr(0, (amount.toString()).length - 1);
	return '.' + amount;
} else if (amount == 0) {
	return "";
} else if (amount == 1 || amount == 2 || amount == 3 || amount == 4
		|| amount == 5 || amount == 6 || amount == 7 || amount == 8
		|| amount == 9) {
	return '.0' + amount;
} else {
	return '.' + amount;
}

}
//鼠标悬停显示提示
function showTips(value, row, index) {
	var content = '';
	if(value != null && value != ''){
	    if(value.length>6 && strDateTime(value)){ //如果为时间
			value = value.substr(0,10);    	
	    }
	    content = '<span title="' + value + '" class="note" >' + value + '</span>';
	}
    return content;
}
function showMoneyTips(value, row, index) {
	var m = formatMoney(value,row,index);
    return showTips(m);
}
//判断是否为时间格式 yyyy-MM-dd HH:mm:ss
function strDateTime(str){
	var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/; 
	var r = str.match(reg); 
	if(r==null)return false; 
	var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]); 
	return (d.getFullYear()==r[1]&&
	(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7
	]);
}



</script>
</head>
<body style="height: 200%">
<div class="jianju" style="height: 1000px;">
<h3>合同高级查询</h3>

<div id="tb" style="padding:5px;height:auto">
<hr/>
	<div>
	  <label style="margin-left:18px">客户手机：</label><input class="easyui-textbox" id="customerPhone" type="number" style="width:120px" placeholder="输入客户手机">
	  <label style="margin-left:18px">客户姓名：</label><input class="easyui-textbox" id="customerName" style="width:110px" placeholder="输入客户姓名"><br />
	  <label style="margin-left:18px">合同状态：</label>
	  	<select id="htzt" class="easyui-combobox" style="width: 100px" valueField="status"
					textField="statustest" method="get" editable="false" panelHeight="auto">
					<option value="">全部</option>
					<option value="50">录入中</option>
					<option value="40">待一审</option>
					<option value="30">待二审</option>
					<option value="60">待放款</option>
					<option value="20">执行中</option>
					<option value="10">逾期中</option>
					<option value="70">已作废</option>
					<option value="90">已结束</option>
				</select>
	  <label style="margin-left:18px">推荐人：</label><input id="recom" class="easyui-textbox" style="width:110px" placeholder="输入推荐人姓名"><br />
	  <label style="margin-left:18px">所属公司：</label>
	<select id="ssgs" class="easyui-combobox" style="width: 100px" 
					mode="remote" url="${ctx}/contractadvancedquery/findUnderCompany" valueField="id"
					textField="orgName" method="get" editable="false" panelHeight="auto">
				</select>
	  <label style="margin-left:18px">申请日期：</label>
	  		<input id="applstartTime" type="text" class="easyui-datebox" style="width:110px" editable="false"/>
			&nbsp;~&nbsp;
			<input id="applendTime" type="text" style="width:110px" class="easyui-datebox" editable="false"/><br />
	  <label style="margin-left:18px">放款日期：</label>
	  		<input id="loanstartTime" type="text" class="easyui-datebox" style="width:110px" editable="false"/>
			&nbsp;~&nbsp;
			<input id="loanendTime" type="text" style="width:110px" class="easyui-datebox" editable="false"/>
	</div>
	  <a id="search" href="#" class="easyui-linkbutton button" style="margin-left:15px;" iconCls="icon-search">查询</a>	
</div>

	<table id="ac" class="easyui-datagrid" 
		url=""
		title="" style="width:98%;minWidth:1000px;" 
		rownumbers="true"  rowStyler="rowStyle"
		onLoadSuccess:function(data){
                $(".note").tooltip({
                    onShow: function(){
                        $(this).tooltip('tip').css({ 
                            width:'300',
                            boxShadow: '1px 1px 3px #292929'       
                                             
                        });
                    }
                });
             } >
		<thead>
			<tr style="background:#148CCA;">
				<th data-options="field:'id',align:'left',formatter:showTips" style="width:6%">合同编号</th>
				<th data-options="field:'underCompany',align:'center',formatter:showTips" style="width:9%">所属公司</th>
				<th data-options="field:'customerName',align:'center',formatter:showTips" style="width:11%">客户姓名</th>
				<th data-options="field:'customerPhone',align:'center',formatter:showTips" style="width:11%">客户手机</th>
				<th data-options="field:'approvalAmount',align:'right',formatter:formatMoney,formatter:showMoneyTips" style="width:8%">产品金额</th>
				<th data-options="field:'totalAmount',align:'right',formatter:formatMoney,formatter:showMoneyTips" style="width:8%">回收金额</th>
				<th data-options="field:'applTime',align:'right',formatter:showTips" style="width:11%">申请日期</th>
				<th data-options="field:'loanTime',align:'right',formatter:showTips" style="width:11%">放款日期</th>
				<th data-options="field:'approvalCyc',align:'right',formatter:showTips" style="width:6%">服务期数</th>
				<th data-options="field:'status',align:'right',formatter:showTexts" style="width:10%">合同状态</th>
				<th data-options="field:'status2',align:'right',formatter:showLinks" style="width:10%">执行详情</th>
			</tr>
		</thead>
	</table>
		  <label style="margin-left:18px">产品金额汇总：</label><input id="approvalAmountSum" class="easyui-textbox" style="width:120px" maxlength="11" readonly="readonly">
	  <label style="margin-left:18px">回收金额汇总：</label><input id="totalAmountSum" class="easyui-textbox" style="width:110px" readonly="readonly"><br />
	
</div>
</body>
</html>